﻿@using ChinaHCM.QA.Site.Model
@using ChinaHCM.QA.Site.Web.Extensions
@using ChinaHCM.QA.Site.Web.Models
@model TopicBBS
@*主贴管理*@
@{Html.RenderAction("TopicManager", "Topic", new { topicId = @Model.Topic.TopicId });}
@*问题*@
<div id="Question" class="DiscussBorder">
    <h3 id="TopicTitle" class="topicCaptionText">
        @Html.GetLock(@Model.Topic.IsLock)
        @Html.GetTopLevl(@Model.Topic.TopLevel)
        @Html.GetDigest(@Model.Topic.IsDigest)
        @Model.Topic.Title</h3>
    <p class="clearfix">
        <span class="Questioner">提问者：@Html.ActionLink(@Model.TopicBBSs.PostUserName, "GetUserInfo","Account", new { userId = @Model.TopicBBSs.PostUserId }, new { target = "_blank" })</span>
        <span class="QuestionTime">发帖时间：
            @Html.DateTimeLeaveString(@Model.TopicBBSs.PostTime)@Html.GetIP(@Model.TopicBBSs.PostIp)</span>
    </p>
    <p class="clearfix">
        关键词：
        @foreach (string str in ViewBag.Keywords)
        { 
            <span class="QuesKeywords">@str</span>
        }
    </p>
    <p class="QuestionDesc">
        @Model.TopicBBSs.Content
    </p>
    <p>
    </p>
</div>
@*正确答案*@
@if (@Model.HasAnswer)
{
    <div id="Answer" class="DiscussBorder">
        <span>
            <img src="@Url.Content("~/images/Best.gif")" />
            最佳回复</span>
        <p class="QuestionDesc">
            @Model.Answer.Content
        </p>
        <p class="clearfix">
            <span class="ReBestAuthorSign">回复者：@Html.ActionLink(@Model.Answer.PostUserName, "GetUserInfo", "Account", new { userId = @Model.Answer.PostUserId }, new { target = "_blank" })
                回复时间：@Html.FormatDateTime(@Model.Answer.PostTime)@Html.GetIP(@Model.Answer.PostIp)</span>
        </p>
        @*可以修改正确答案，但是不能取消。取消操作替换为从其他回答中选择正确答案*@
        <script language="javascript">
            function LoadEdit() {
                try {
                    $.ajax({
                        type: "Get",
                        url: "@Url.Action("GetEditAnswer", "BBS", new { bbsId = @Model.Answer.BBSId })",
                        async: false,
                        success: function (msg) {
                            $("#EditMyAnswer").empty();
                            $('#EditMyAnswer').append(msg);
                        }
                    });
                }
                catch (e) { }
            }       
            function Close()
            {
            $("#EditMyAnswer").empty();
            $('#EditMyAnswer').append(" <input type=\"submit\" id=\"EditAnswer\" value=\"修改答案\" onclick=\"LoadEdit()\" />");
            }  
        </script>
        <div id="EditMyAnswer">
            <input type="submit" id="EditAnswer" value="修改答案" onclick="LoadEdit()" />
        </div>
    </div>
}
@*其他答案*@
@if (Model.AnswerCnt > 0)
{ 
    <div id="OtherAnswerList" class="DiscussBorder">
        <span class="ReOther">回 答 共
            @Model.AnswerCnt
            条</span>
        @foreach (BBSView bbs in this.Model.OtherBBSs.OrderBy(b => b.PostTime))
        { 
            <div class="OtherAnswer clearfix">
                <p class="clearfix">
                    <span class="Questioner">回复者：@Html.ActionLink(@bbs.PostUserName, "GetUserInfo", "Account", new { userId = @bbs.PostUserId }, new { target = "_blank" })</span>
                    <span class="QuestionTime">回复时间：@Html.FormatAllDateTime(@bbs.PostTime)@Html.GetIP(@bbs.PostIp)</span>
                </p>
                <p class="QuestionDesc">
                    @bbs.Content
                </p>
                @*帖子管理*@
                @{Html.RenderAction("BBSManager", "BBS", new { bbsId = @bbs.BBSId });}
            </div>
        }
    </div>
}
@*通过浮动层完成回复操作*@